﻿using System;
using System.Collections.Generic;
using System.DirectoryServices;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static string LDapPath = "LDAP://ldap.chinascopefinancial.com";
        static string Name = "hao.wang@chinascopefinancial.com";
        static string Password = "wangfei808";
        static void Main(string[] args)
        {
            try
            {
                using (var ldap = new DirectoryEntry(LDapPath, string.Format("uid={0},dc=employees,dc=people,dc=chinascopefinancial,dc=com", Name), Password, AuthenticationTypes.None))
                {
                    var n = ldap.Name;
                    Console.WriteLine(n);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadKey();
        }
    }
}
